package com.yc.SelectCourse.ui;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

import java.util.Iterator;
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.widgets.Label;
import org.eclipse.wb.swt.SWTResourceManager;

import com.yc.SelectCourse.util.StuUtils;

import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Combo;
import swing2swt.layout.BorderLayout;

public class StudentMainUI {

	protected Shell shell;
	

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			StudentMainUI window = new StudentMainUI();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(1019, 816);
		shell.setText("SWT Application");
		shell.setLayout(new BorderLayout(0, 0));
		//窗口居中
		StuUtils.centerWindows(shell);
		Composite composite = new Composite(shell, SWT.NONE);
		composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_CYAN));
		composite.setLayoutData(BorderLayout.WEST);
		
		Label lblNewLabel_1 = new Label(composite, SWT.NONE);
		lblNewLabel_1.setImage(SWTResourceManager.getImage(StudentMainUI.class, "/image/xiyouji.jpg"));
		lblNewLabel_1.setBounds(10, 71, 142, 114);
		
		Button btnNewButton = new Button(composite, SWT.NONE);
	
		btnNewButton.setForeground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_FOREGROUND));
		btnNewButton.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 14, SWT.NORMAL));
		btnNewButton.setBounds(0, 274, 165, 37);
		btnNewButton.setText("学生选课");
		
		Button btnNewButton_1 = new Button(composite, SWT.NONE);
		
		btnNewButton_1.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 14, SWT.NORMAL));
		btnNewButton_1.setBounds(0, 358, 165, 42);
		btnNewButton_1.setText("选课查询");
		
		Button btnNewButton_2 = new Button(composite, SWT.NONE);
		btnNewButton_2.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 14, SWT.NORMAL));
		btnNewButton_2.setBounds(0, 440, 165, 42);
		btnNewButton_2.setText("学籍信息");
		
		Button button = new Button(composite, SWT.NONE);
		button.setBounds(29, 638, 80, 27);
		button.setText("登出");
		
		Composite composite_1 = new Composite(shell, SWT.NONE);
		composite_1.setLayoutData(BorderLayout.CENTER);
		composite_1.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		
		Label lblNewLabel = new Label(shell, SWT.CENTER);
		lblNewLabel.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 24, SWT.NORMAL));
		lblNewLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_GREEN));
		lblNewLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		lblNewLabel.setLayoutData(BorderLayout.NORTH);
		lblNewLabel.setText("学  籍  信  息  管  理  系  统  ");
		
		IndexCmp indexCmp = new IndexCmp(composite_1, SWT.NONE);
		
		
		
		//学生选课
		
		btnNewButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				StuUtils.delectCompositeControl(composite_1);
				StudentSelectCourseCmp studentSelectCourseCmp = new StudentSelectCourseCmp(composite_1, SWT.NONE);
				composite_1.requestLayout();
			}
		});
		//查看选课
		btnNewButton_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				StuUtils.delectCompositeControl(composite_1);
				FindSelectedCourseUI findSelectedCourseUI = new FindSelectedCourseUI(composite_1, SWT.NONE);
				composite_1.requestLayout();
			}
		});
	}
}
